/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: nu uc
 * License Type: Evaluation
 */
package org.testis.orm.classes;

import org.orm.*;

public class T_bed_os {
    public T_bed_os() {
    }

    public boolean save() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .saveObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean delete() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .deleteObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean refresh() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().refresh(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean evict() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().evict(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate() throws PersistentException {
	try {
	    org.testis.orm.classes.T_bed_devicegroup_details[] lT_bed_devicegroup_detailss = t_bed_devicegroup_details
		    .toArray();
	    for (int i = 0; i < lT_bed_devicegroup_detailss.length; i++) {
		lT_bed_devicegroup_detailss[i].setOs(null);
	    }
	    return delete();
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate(org.orm.PersistentSession session)
	    throws PersistentException {
	try {
	    org.testis.orm.classes.T_bed_devicegroup_details[] lT_bed_devicegroup_detailss = t_bed_devicegroup_details
		    .toArray();
	    for (int i = 0; i < lT_bed_devicegroup_detailss.length; i++) {
		lT_bed_devicegroup_detailss[i].setOs(null);
	    }
	    try {
		session.delete(this);
		return true;
	    } catch (Exception e) {
		return false;
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    private java.util.Set this_getSet(int key) {
	if (key == org.testis.orm.manager.ORMConstants.KEY_T_BED_OS_T_BED_DEVICEGROUP_DETAILS) {
	    return ORM_t_bed_devicegroup_details;
	}

	return null;
    }

    org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
	public java.util.Set getSet(int key) {
	    return this_getSet(key);
	}

    };

    private int id;

    private String name;

    private java.util.Set ORM_t_bed_devicegroup_details = new java.util.HashSet();

    private void setId(int value) {
	this.id = value;
    }

    public int getId() {
	return id;
    }

    public int getORMID() {
	return getId();
    }

    public void setName(String value) {
	this.name = value;
    }

    public String getName() {
	return name;
    }

    private void setORM_T_bed_devicegroup_details(java.util.Set value) {
	this.ORM_t_bed_devicegroup_details = value;
    }

    private java.util.Set getORM_T_bed_devicegroup_details() {
	return ORM_t_bed_devicegroup_details;
    }

    public final org.testis.orm.classes.T_bed_devicegroup_detailsSetCollection t_bed_devicegroup_details = new org.testis.orm.classes.T_bed_devicegroup_detailsSetCollection(
	    this,
	    _ormAdapter,
	    org.testis.orm.manager.ORMConstants.KEY_T_BED_OS_T_BED_DEVICEGROUP_DETAILS,
	    org.testis.orm.manager.ORMConstants.KEY_T_BED_DEVICEGROUP_DETAILS_OS,
	    org.testis.orm.manager.ORMConstants.KEY_MUL_ONE_TO_MANY);

    public String toString() {
	return toString(false);
    }

    public String toString(boolean idOnly) {
	if (idOnly) {
	    return String.valueOf(getId());
	} else {
	    StringBuffer sb = new StringBuffer();
	    sb.append("T_bed_os[ ");
	    sb.append("Id=").append(getId()).append(" ");
	    sb.append("Name=").append(getName()).append(" ");
	    sb.append("T_bed_devicegroup_details.size=")
		    .append(t_bed_devicegroup_details.size()).append(" ");
	    sb.append("]");
	    return sb.toString();
	}
    }

}
